package com.yun.springbootsecurity.mapper;

import com.yun.springbootsecurity.pojo.User;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

@Mapper
public interface UserMapper {

    @Select("select * from t_user where username = #{username}")
    @Results({
            @Result(id = true, column = "user_id", property = "userId"),
            @Result(column = "username", property = "userName"),
            @Result(column = "password", property = "password"),
            @Result(column = "user_id", property = "userRoleList", many = @Many(select = "com.yun.springbootsecurity.mapper.UserRoleMapper.getUserRoleByUserId", fetchType = FetchType.LAZY))
    })
            User selectByUserId(String username);
}
